﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ALDIOrganizer.Properties;

namespace ALDIOrganizer
{
    public static class WeekdayExtensionMethods
    {
        public static int ToInt1(this Weekday w)
        {
            return (int)w + 1;
        }
        public static int ToInt0(this Weekday w)
        {
            return (int)w;
        }

        public static int AsFlag(this Weekday pDay)
        {
            return 1 << pDay.ToInt0();
        }

        public static string Plural(this Weekday pDay)
        {
            switch (pDay)
            {
                case Weekday.Monday:
                    {
                        return Resources.PluralWeekday_Mondays;                        
                    }
                case Weekday.Tuesday:
                    {
                        return Resources.PluralWeekday_Tuesdays;
                    }
                case Weekday.Wednesday:
                    {
                        return Resources.PluralWeekday_Wednesdays;
                    }
                case Weekday.Thursday:
                    {
                        return Resources.PluralWeekday_Thursdays;
                    }
                case Weekday.Friday:
                    {
                        return Resources.PluralWeekday_Fridays;
                    }
                case Weekday.Saturday:
                    {
                        return Resources.PluralWeekday_Saturdays;
                    }
                case Weekday.Sunday:
                    {
                        return Resources.PluralWeekday_Sundays;
                    }                
            }
            return String.Empty;
        }

        public static DayOfWeek ToDayOfWeek(this Weekday pWeekday)
        {
            if (pWeekday == Weekday.Sunday)
            {
                return DayOfWeek.Sunday;
            }
            /* Weekday: Monday = 0, Tuesday = 1, Wednesday = 2 etc.
             * DayOfWeek: Sunday = 0... Monday = 1, Tuesday = 2 etc.
             * Hence: DayOfWeek.Monday = Weekday.Monday + 1. etc. */
            var i = (int)pWeekday;
            return (DayOfWeek)(i + 1);
        }

        
    }
}
